|
|
 |
|
|
|
|
'***************************************
'* Alternate Method
'***************************************
'With oIni
' txtKeyValue = .KeyGet(txtSection, _
txtKeyName, _
"")
'End With
Set oIni = Nothing
End Sub |
|
|
|
|
|
|
|
|
Notice that at the end of this routine I have commented out an alternate way to get databy passing all the relevant information directly to the KeyGet() method. |
|
|
|
|
|
|
|
|
The KeyGet() Method in the INI Class |
|
|
|
|
|
|
|
|
The KeyGet() method in the INI class accepts optional arguments for the section name, the key name, and the default value (in case you dont find the value youre after). Notice that each of the optional arguments has a default value. You can check each of the arguments against their default values to see whether any have been passed into the method. If any have been passed in, you override the module-level variable that corresponds to the argument. After all the module-level variables are set, you fill the mstrKeyValue variable to contain 255 spaces. You then call the GetPrivateProfileString() function to retrieve the information from the INI file. Heres the code: |
|
|
|
 |
|
|
|
|
Public Function KeyGet( _
Optional strSection As String = "NA", _
Optional strKeyName As String = "NA", _
Optional strDefault As String = "") _
As String
Dim lngRet As Long
' Fill in properties
If strSection <> "NA" Then
mstrSection = strSection
End If
If strKeyName <> "NA" Then
mstrKeyName = strKeyName
End If |
|
|
|
|
|